package com.hst.capacity.infra.persistence.jpa.marketing.promotion;


import com.hst.capacity.domain.model.entity.marketing.promotion.PromotionRelationEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface PromotionRelationRepository extends JpaRepository<PromotionRelationEntity, String> {

    @Transactional(rollbackFor = Exception.class)
    @Modifying
    @Query("delete from PromotionRelationEntity p where p.idPromotion = ?1")
    void deleteByIdPromotion(String idPromotion);

    @Transactional(rollbackFor = Exception.class)
    @Modifying
    @Query("delete from PromotionRelationEntity p where p.idPromotion = ?1 and p.idCouponRule = ?2")
    void deleteByIdPromotionAndAndIdCouponRule(String idPromotion,String idCouponRule);

}